"use strict";
/**
 * mongodb 数据库连接
 */
const Mongodb = require("@pick-star/cli-mongodb");
const { mongodbUrl, mongodbDbName } = require("../../config/db");
class MongodbCli extends Mongodb {
  find(docName, queryCollection) {
    return this.connectAction(docName, (collection, onSuccess, onError) => {
      collection
        .find(queryCollection, { projection: { _id: 0 } })
        .toArray((err, docs) => {
          if (err) {
            onError(err);
          } else {
            onSuccess(docs);
          }
        });
    });
  }
}
function mongo() {
  return new MongodbCli(mongodbUrl, mongodbDbName);
}
module.exports = mongo;
